#ifndef PACKET_INFO_H_
#define PACKET_INFO_H_

#include "uthash.h"
#include "cope-packet.h"
#include <list>
#include <ext/hash_set>
using std::list;
using namespace __gnu_cxx;

/* this is the key of the hash table */
/* typedef struct { */
/*     int pkt_id; */
/*     int nodeid; */
/* } info_key_t; */

/* /\* the real hash table entry *\/ */
/* typedef struct { */
/*     info_key_t key; */
/*     bool prob; */
/*     UT_hash_handle hh; */
/* } packet_info_t; */

typedef struct {
    int nodeid;
    hash_set<int> pkt_ids;
} pkt_info_t;


class PacketInfo {
 public:
    PacketInfo();
    ~PacketInfo();

   
    /* get prob for a specific neighbor and pkt_id */
    bool get_prob(int nb, int pkt_id);  
 
    /* update packet info when receive a state report */
    void update_pkt_info(hdr_report_t, int, int);
    /* 
     * update packet info when receive a packet, which means
     * the previous hop will have the packets for sure
     */
    void update_pkt_info(Packet * p, int);
    
    void update_pkt_info(int pktid, int nodeid);
    
    /*
     * get the number of pkts from start_seq to last_seq for src_ip,
     * this is mainly used by ProbGuess class
     */
    int get_pkt_count(int /* nb */,
		      nsaddr_t /* src_ip */,
		      uint16_t /* start_seq_num */, 
		      uint16_t /* last_seq_num */);

    //    int checkpktinfo(info_key_t key);
 private:
    /*
     * the packet info hash table to store the probability of
     * each neighbor having that pakcet
     */
    list<pkt_info_t> pkt_info_table_;
    /* packet_info_t* pkt_info_table_; */
    
};

#endif
